﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cricket.LinqData;
using Cricket.LinqModel;

public partial class ChangePassword : System.Web.UI.Page
{
    #region Variable Declaration
    IDataRepository _dataObject = new DataRepository();
    Admin admin;
    AdminCredential adminCredentail;
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            HttpCookie cookie = Request.Cookies["Admin"];
            if (cookie == null)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        adminCredentail = new AdminCredential(_dataObject);
        HttpCookie cookie = Request.Cookies["Admin"];
        adminCredentail.AdminId = Convert.ToInt32(cookie["AdminId"]);
        adminCredentail.BatId = 1;
        adminCredentail.Password1 = txtMatchPassword1.Text;
        adminCredentail.Password2 = txtMatchPassword2.Text;
        adminCredentail.UpdateAdminCredentials();

        adminCredentail.AdminId = Convert.ToInt32(cookie["AdminId"]);
        adminCredentail.BatId = 2;
        adminCredentail.Password1 = txtSessionPassword1.Text;
        adminCredentail.Password2 = txtSessionPassword2.Text;
        adminCredentail.UpdateAdminCredentials();

        adminCredentail.AdminId = Convert.ToInt32(cookie["AdminId"]);
        adminCredentail.BatId = 3;
        adminCredentail.Password1 = txtFancyPassword1.Text;
        adminCredentail.Password2 = txtFancyPassword2.Text;
        adminCredentail.UpdateAdminCredentials();

        admin = new Admin(_dataObject);
        admin.Id = Convert.ToInt32(cookie["AdminId"]);
        admin.UpdateAdminFlag();
        Response.Redirect("Dashboard.aspx");
    }
}